Skip to content

feat(coprocessor): add local coverage tooling and pre-push hook#2095

Closed
PanGan21 wants to merge 7 commits intopanos/add-coverage-toolfrom
panos/pre-push-coverage
Closed

feat(coprocessor): add local coverage tooling and pre-push hook#2095
PanGan21 wants to merge 7 commits intopanos/add-coverage-toolfrom
panos/pre-push-coverage

Conversation

@PanGan21
Copy link
Copy Markdown
Contributor

@PanGan21 PanGan21 commented Mar 11, 2026

Summary

  • Add Makefile targets for running code coverage locally: full coprocessor workspace (make coverage), single crate (make coverage-crate CRATE=<name>), or only changed crates (make coverage-changed)
  • make coverage-changed compares against main, detects which crates have changes, and runs coverage only for those
  • Add a pre-push git hook that warns if you haven't run coverage before pushing crate changes (non-blocking — never prevents a push)
  • Add scripts to install/uninstall the git hook (sh .githooks/install.sh / sh .githooks/uninstall.sh)

Developer workflow

  1. Run ./githooks/install.sh once to enable the pre-push hook
  2. Make changes to coprocessor crates as usual
  3. Before pushing, run make coverage-changed in coprocessor/fhevm-engine/ — it auto-detects which crates changed vs main and suggests to run coverage only for those
  4. On git push, the hook checks for a fresh coverage report. If missing or stale, it prints a warning (never blocks the push)

Ouput

=> git push

Coverage: Lines: 20.35% | Functions: 25.20% | Regions: 20.45%

@PanGan21 PanGan21 requested review from a team as code owners March 11, 2026 12:39
@cla-bot cla-bot bot added the cla-signed label Mar 11, 2026
@PanGan21 PanGan21 requested a review from Eikix March 11, 2026 12:39
@PanGan21
Copy link
Copy Markdown
Contributor Author

@claude /pr-review

@claude
Copy link
Copy Markdown

claude bot commented Mar 11, 2026

Claude timed out while processing the request. — View run

@PanGan21
Copy link
Copy Markdown
Contributor Author

@claude /pr-review

@claude
Copy link
Copy Markdown

claude bot commented Mar 11, 2026

Claude finished @PanGan21's request.View run

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AUTOMATED]

Code Review

Overall this is a well-structured PR that adds useful local coverage tooling. The shell scripts are defensive and the non-blocking hook design is sensible. However, there is one significant issue with how the new hooks system interacts with the existing one.

Checked for: bugs, guideline compliance, error handling, and security.

Issues found: 2 (1 high, 1 low)

# Sets up .githooks/ as the git hooks directory for this repository.
#
cd "$(git rev-parse --show-toplevel)" || exit 1
git config core.hooksPath .githooks
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AUTOMATED]

Setting core.hooksPath silently disables existing git hooks (confidence: 97/100)

git config core.hooksPath .githooks causes Git to exclusively use .githooks/ for hook resolution, completely bypassing .git/hooks/. This means any hooks previously installed via .github/hooks/install.sh are silently disabled:

  • .github/hooks/pre-push (blocking): runs cargo fmt --check, cargo clippy -- -D warnings, and cargo test — these quality gates are lost
  • .github/hooks/commit-msg: enforces Angular conventional commit format — also lost

The new .githooks/pre-push does not chain to or invoke the old hooks, and .githooks/ has no commit-msg hook at all. A developer who previously had the old hooks installed and follows the README to install these new hooks will unknowingly lose their quality gates.

Suggested fix (pick one):

  1. Consolidate (recommended): Add the coverage logic to the existing .github/hooks/pre-push instead of creating a parallel hooks system.

  2. Chain hooks: Have .githooks/pre-push invoke the old hook first:

    OLD_HOOK="$(git rev-parse --show-toplevel)/.github/hooks/pre-push"
    if [ -x "$OLD_HOOK" ]; then
        "$OLD_HOOK" "$@" || exit $?
    fi

    And add a commit-msg passthrough in .githooks/ as well.

  3. At minimum: Warn the user in install.sh and the README that this replaces the default hooks directory.

Copy link
Copy Markdown
Contributor Author

@PanGan21 PanGan21 Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the existing githook for fmt and clippy seems broken I keep the existing directory and only warn the user about overriding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added both hooks in the same directory and the developer has a choice to install one githook or both.

@claude
Copy link
Copy Markdown

claude bot commented Mar 11, 2026

Review posted successfully. Here's a summary:

PR Review Summary — #2095

PR: feat(coprocessor): add local coverage tooling and pre-push hook

Overall this is a well-structured PR with useful local coverage tooling. The shell scripts are defensive, the non-blocking hook design is sensible, and the auto-detection of changed crates is a nice workflow improvement.

Issues Found: 2

# Severity File Issue
1 High (97/100) .githooks/install.sh:6 core.hooksPath silently disables existing git hooks (pre-push quality gates + commit-msg)
2 Low/Nit (85/100) .githooks/pre-push:69 stat fallback missing guard — can produce visible shell error on unusual platforms

The main concern is that git config core.hooksPath .githooks completely replaces the hooks directory, silently disabling the existing .github/hooks/pre-push (which enforces cargo fmt, cargo clippy, cargo test) and the commit-msg hook. The review suggests either consolidating into the existing hooks system, chaining the hooks, or at minimum warning users.

Review link

@PanGan21 PanGan21 force-pushed the panos/pre-push-coverage branch from 90470de to c5aa5a2 Compare March 11, 2026 15:26
@PanGan21
Copy link
Copy Markdown
Contributor Author

For this to be effective in the development workflow, the pre-push hook would need to be enforced. Otherwise, running it would remain optional for developers.

Given that, this PR doesn’t seem to provide much value at the moment and would mainly add additional local execution time. For that reason, I’m closing the PR.

@PanGan21 PanGan21 closed this Mar 11, 2026
@mergify
Copy link
Copy Markdown

mergify bot commented Mar 11, 2026

🧪 CI Insights

Here's what we observed from your CI run for c5aa5a2.

🟢 All jobs passed!

But CI Insights is watching 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant